import {
  CHANGE_PROFILE_COLLECT_NOTE,
  CHANGE_PROFILE_MY_NOTE,
} from "./constant";
import { getAllMyNote, getCollectNote } from "@/services";

// 获取个人发表的笔记
const changeProfileNoteAction = (data) => ({
  type: CHANGE_PROFILE_MY_NOTE,
  data,
});

export const getProfileMyNoteAction = (userId) => {
  return (dispatch) => {
    getAllMyNote(userId).then((res) => {
      dispatch(changeProfileNoteAction(res.data.list));
    });
  };
};

// 获取收藏的笔记
const changeProfileCollectNoteAction = (data) => ({
  type: CHANGE_PROFILE_COLLECT_NOTE,
  data,
});
export const getProfileCollectNoteAction = (userId) => {
  return (dispatch) => {
    getCollectNote(userId).then((res) => {
      dispatch(changeProfileCollectNoteAction(res.data.list));
    });
  };
};
